import {defineConfig} from 'vite'
import vueConfigJs from "./vue.config";
// import resolve from '@rollup/plugin-node-resolve';
// import commonjs from '@rollup/plugin-commonjs';
// import terser from '@rollup/plugin-terser'

const buildName = 'ColorUtils'
const types = ['umd', 'es', 'cjs']

export default defineConfig(({command, mode}) => {
  return {
    publicDir: false,
    build: {
      outDir: './dist',
      lib: {
        entry: './local_modules/ZhiXinLib/buildUtils.js',
        name: buildName,
      },
      rollupOptions: {
        // 确保外部化处理那些你不想打包进库的依赖
        external: ['vue'],
        output: types.map(i => {
          return {
            entryFileNames: `${buildName}.${i}.js`,
            extend: true,
            format: i,
          }
        })
      }
    },
    resolve: {
      alias: {
        ...vueConfigJs.configureWebpack.resolve.alias,
      },
      extensions: vueConfigJs.configureWebpack.resolve.extensions
    }
  }
})
